package com.game.modular.game.act.battle;

import com.game.comment.core.ResponseResult;
import com.game.comment.util.JwtUtils;
import com.game.modular.game.act.battle.vo.BattleVo;
import com.game.modular.game.playerMatch.service.PvpCityServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@Api(tags = "pvp路线信息")
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("/pvpRouteAct")
public class PvpLinkAction {
    @Resource
    private PvpCityServiceImpl CityService;

    @ApiOperation("查询当前移动路线")
    @PostMapping("/bfsAllPaths")
    public ResponseResult<?> bfsAllOwnerPaths(
            @RequestHeader String token,
            @Valid @RequestBody BattleVo.PvpLinkVo.bfsVo param
    ) {
        return ResponseResult.success(CityService.bfsAllPaths(
                param.getStartCityId(), param.getTargetCityId())
        );
    }

    @ApiOperation("查询当前移动最短路线")
    @PostMapping("/bfsAllMinPaths")
    public ResponseResult<?> bfsAllOwnerMinPaths(
            @RequestHeader String token,
            @Valid @RequestBody BattleVo.PvpLinkVo.bfsVo param
    ) {
        Long playerId = JwtUtils.getPlayerId(token);
        return ResponseResult.success(
                CityService.bfsMinPaths(
                        param.getStartCityId(), param.getTargetCityId()
        ));
    }
}
